<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%
    /**
     * @Description :  General Board
     * @Modification Information
     *
     *   수정일               수정자                   수정내용
     *  -------    --------    ---------------------------
     *
     *
     */
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
<title><tiles:insertAttribute name="headtitle" ignore="true"/></title>

<link rel="stylesheet" type="text/css" media="screen" href="<c:url value='/resources/css/jquery/start/jquery-ui-1.10.3.custom.css'/>" />
<link rel="stylesheet" type="text/css" media="all"  href="<c:url value='/resources/css/kickstart/kickstart.css'/>"/> <!-- KICKSTART -->

<script type="text/javascript" src="<c:url value='/resources/js/jquery/jquery-1.9.0.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/jquery/jquery-ui-1.10.3.custom.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/kickstart/kickstart.js'/>"></script> <!-- KICKSTART -->
<%@include file="/WEB-INF/jsp/common/commonJs.jsp"%> 

<!-- additional -->
<script type="text/javascript" src="<c:url value='/resources/js/jquery/plugin/form/jquery.form.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/jquery/plugin/validate/jquery.validate.min.js'/>"></script>
<!-- //additional -->

<script type="text/javascript">
$(document).ready(function() {
	
//********************************************************
// event handler area   
//********************************************************  
    $("#btnRegistForm").click(function() { // 폼이동(신규)
        event.preventDefault();
        $("#form1").prop("action",'<c:url value="/bbs/bbsGeneralBoard/form"/>?bbs_id=${params.bbs_id}');
        $("#action_name").val("NEW_FORM");
        $("#form1").submit();       
    }); 
    
	// 페이지초기화
    initPage();
});
   

//********************************************************
// page init/finalize area   
//********************************************************
/**
 * initialize page 
 */ 
var initPage = function() {
};

/**
 * finalize page 
 */ 
var finalizePage = function() {
}; 


//********************************************************
// form validation area   
//********************************************************  

//********************************************************
// form process area   
//******************************************************** 
var goPage = function(pageNo) { // 페이지이동
    $("#form1").prop("action",'<c:url value="/bbs/bbsGeneralBoard/list"/>?bbs_id=${params.bbs_id}');
    $("#action_name").val("MOVE_PAGE");
    $("#page_no").val(pageNo);
    $("#form1").submit();
};

var detailForm = function(atclId) { // 폼이동(상세보기)
    $("#form1").prop("action",'<c:url value="/bbs/bbsGeneralBoard/form"/>?bbs_id=${params.bbs_id}');
    $("#action_name").val("DETAIL_FORM");
    $("#atcl_id").val(atclId);
    $("#form1").submit();
};
</script>
</head>
<body>
*Params:<br>
  ${params}<br>
  
<!-- Table -->
<table cellspacing="0" cellpadding="0">
<thead>
    <tr>
        <th>번호</th>
        <th>제목</th>
        <th>작성자</th>
        <th>작성일</th>
        <th>조회</th>
        <th>추천</th>
    </tr>
</thead>
<tbody>
<c:if test="${empty list}">
    <tr>
        <td>
            결과데이터가 존재하지 않습니다.
        </td>
    </tr>
</c:if>
<c:forEach var="row" items="${list}" varStatus="status">
    <tr>
        <td>${row.ATCL_ID}</td>
        <td>
            <c:if test="${row.DEL_YN != 'Y'}">
                <c:if test="${row.DEPTH != 0}">
                    <c:forEach begin="0" end="${row.DEPTH}" step="1">
                        &nbsp;
                    </c:forEach>
                    <img src="<c:url value='/resources/images/bbs/reply_arrow.gif'/>">
                </c:if>                
                <a href="javascript:detailForm(${row.ATCL_ID})">${row.SUBJECT}</a>
            </c:if>
            <c:if test="${row.DEL_YN == 'Y'}">
                이 글은 작성자에 의해서 삭제되었습니다.
            </c:if>
        </td>
        <td>${row.MEM_NAME}</td>
        <td>${row.CREATE_DATE}</td>
        <td>${row.READ_CNT}</td>
        <td>${row.RCMD_CNT}</td>
    </tr>
</c:forEach> 
</tbody>
</table>

<!-- paginator -->
<div class="col_12 center">
    <c:choose>
        <c:when test="${paginator.groupNo != 1 }">
                    <a href="javascript:goPage(1)"><font size="3"> &lt;&lt;&lt; </font></a>
                    &nbsp;&nbsp;
                    <a href="javascript:goPage(${paginator.prevGroupPage})"><font size="3"> [ prev ]</font></a>
                    &nbsp;&nbsp;    
        </c:when>
        <c:otherwise>
                    <font size="3"> &lt;&lt;&lt; </font>
                    &nbsp;&nbsp;
                    <font size="3"> [ prev ]</font>    
        </c:otherwise>
    </c:choose>
    <c:forEach var="i" begin="${paginator.startPage}" end="${paginator.endPage}" varStatus="status">
        <c:choose>
            <c:when test="${paginator.pageNo == i}">
                    &nbsp;${i}&nbsp;
            </c:when>
            <c:otherwise>
                    <a href="javascript:goPage(${i})"><font color="" size="3"> [${i}] </font></a>
            </c:otherwise>
        </c:choose>                
                    
    </c:forEach>
    <c:choose>
        <c:when test="${paginator.groupNo < paginator.totalPageGroupCnt }">
                     &nbsp;&nbsp;
                    <a href="javascript:goPage(${paginator.nextGroupPage})"><font size="3"> [ next ]</font></a>
                    &nbsp;&nbsp;
                    <a href="javascript:goPage(${paginator.totalPageCnt})"><font size="3"> &gt;&gt;&gt; </font></a>
        </c:when>
        <c:otherwise>
                    &nbsp;&nbsp;
                    <font size="3"> [ next ]</font>
                    &nbsp;&nbsp;
                    <font size="3"> &gt;&gt;&gt; </font>
        </c:otherwise>
    </c:choose>    
</div>  
<!-- //paginator -->

<form id="form1" name="form1" method="post">
    <input type="hidden" id="bbs_id" name="bbs_id" value="${params.bbs_id}"/>
    <input type="hidden" id="page_no" name="page_no" value="${paginator.pageNo}"/>
    <input type="hidden" id="action_name" name="action_name" value=""/>
    <input type="hidden" id="atcl_id" name="atcl_id" value=""/><!-- 글번호 -->
</form>
<div class="col_12 center">
    <button id="btnRegistForm">신규</button>
</div>

</body>
</html>